#include "integer.h"
#include "fattime.h"
#include "fw/vbb_RTC.h"

#ifndef __TINY_TEST__
extern VBB_RTC rtc;
#else
VBB_RTC rtc;
#endif

BOOL gettime (RTC_T * _rtc)
{
	_rtc->sec = rtc.second;
	_rtc->min = rtc.minute;
	_rtc->hour = rtc.hour;
	_rtc->mday = rtc.day;
	_rtc->month = rtc.month;
	_rtc->year = rtc.year;
	return TRUE;
}

BOOL settime (const RTC_T * _rtc)
{	
	return TRUE;
}

DWORD get_fattime (void)
{
	RTC_T _rtc;
	
	/* Get local time */
	gettime(&_rtc);

	/* Pack date and time into a DWORD variable */
	return	  ((DWORD)(_rtc.year - 1980) << 25)
			| ((DWORD)_rtc.month << 21)
			| ((DWORD)_rtc.mday << 16)
			| ((DWORD)_rtc.hour << 11)
			| ((DWORD)_rtc.min << 5)
			| ((DWORD)_rtc.sec >> 1);
}

